import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Array;
import java.util.*;
public class Main {
    public static void main(String[] args) throws IOException {
        ArrayList<String> total = new ArrayList<String>();
        ArrayList<String> now = new ArrayList<String>();
        func1(total);
        func1(now);
        //去重
        for (String str: now) {
            int i = 0;
            for (; i < total.size(); i++) {
                if (total.get(i).equals(str)) {
                    total.remove(i);
                    break;
                }
            }
        }
        //分行写文件
        save("C:\\Users\\zyp19\\Desktop\\test.txt",total);
    }
    public static void func1(ArrayList<String> list) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String line = scanner.nextLine();
            if (line.equals("exit")){
                return;
            }else{
                list.add(line);
            }
        }
    }
    public static void save(String filePath, List<String> names) throws IOException {
        Writer writer = new FileWriter(filePath);
        for (String name : names) {
            writer.write(name + "\n");
        }
        writer.close();
    }
}